package com.lyl.security.common.exception;

import cn.hutool.core.util.StrUtil;
import com.lyl.security.common.result.BizCode;
import com.lyl.security.common.result.ResultCode;
import lombok.Data;
import lombok.EqualsAndHashCode;

@EqualsAndHashCode(callSuper = true)
@Data
public class BizException extends RuntimeException{
    private BizCode bizCode;
    private String msg;


    public BizException(String msg) {
        this(ResultCode.BIZ_ERROR, msg);
    }


    public BizException(BizCode bizCode) {
        this(bizCode, null);
    }

    public BizException(BizCode bizCode, String msg) {
        super(StrUtil.blankToDefault(msg,bizCode.getMsg()));
        this.bizCode = bizCode;
        this.msg = StrUtil.blankToDefault(msg,bizCode.getMsg());
    }
}
